package com.lc.luzhengtang.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lc.luzhengtang.R;
import com.lc.luzhengtang.bean.SearchBean;

import java.util.List;

/**
 * 文 件 名: NewsListAdapter
 * 创 建 人: zhangyu
 * 创建日期: 16/12/24 19:55
 * 邮   箱: yuanchong121@gmail.com
 * 修改时间：
 * 修改备注：
 */
public class SearchAdapter extends BaseAdapter {
    private List<SearchBean.DataBeanX.DataBean> shoppingCartBeanList;
    private Context context;
    public SearchAdapter(Context context, List<SearchBean.DataBeanX.DataBean> shoppingCartBeanList) {
        this.context = context;
        this.shoppingCartBeanList = shoppingCartBeanList;
    }
    @Override
    public int getCount() {
        return shoppingCartBeanList.size();
    }

    @Override
    public Object getItem(int position) {
        return shoppingCartBeanList.get(position).getTitle();
    }

    @Override
    public long getItemId(int position) {
        return shoppingCartBeanList.get(position).getId();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final SearchAdapter.ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.spinner_list_item2, parent, false);

            holder = new SearchAdapter.ViewHolder(convertView);
            convertView.setTag(holder);

        } else {
            holder = (SearchAdapter.ViewHolder) convertView.getTag();
        }

        holder.text_item.setText(shoppingCartBeanList.get(position).getTitle());

        return convertView;
    }

    class ViewHolder {
        TextView text_item;
        public ViewHolder(View itemView) {
            text_item= (TextView) itemView.findViewById(R.id.text_item);
        }
    }
}
